home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / FATTR.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  108 lines

  1. //--------------------------------------------------------------------
  2. // FATTR.AML
  3. // Change Attributes, (C) 1993-1996 by nuText Systems
  4. //
  5. // (See Fattr.dox for user help)
  6. //
  7. // This macro displays and optionally changes file or directory
  8. // attributes.
  9. //
  10. // When run from an edit window, the attributes of the current file are
  11. // changed to the new attributes.
  12. //
  13. // When run from a file manager window, the attributes of the current
  14. // file (or marked files) are changed to the new attributes.
  15. //
  16. // Usage:
  17. //
  18. // Select this macro from the Macro List (on the Macro menu), or run it
  19. // from the macro picklist <shift f12>.
  20. //
  21. // This macro can also be run from the file manager by selecting the
  22. // Attributes.. item from the Command menu.
  23. //--------------------------------------------------------------------
  24.  
  25. // compile time macros and function definitions
  26. include bootpath "define.aml"
  27.  
  28. macrofile = arg 1
  29.  
  30. // called by Lib.x when a key is entered in the dialog box
  31. function ondialog (keycode)
  32.   // macro help
  33.   if keycode == <f1> then
  34.     helpmacro macrofile
  35.   end
  36. end
  37.  
  38. // change attribute dialog box
  39. private function askattr (file attr)
  40.  
  41.   file = onname file
  42.  
  43.   // used dialog box
  44.   if _PromptStyle == 'd' then
  45.  
  46.     dialog file 31 7 "cp"
  47.  
  48.     groupbox 'Attributes:' 3 2
  49.       (menu ''
  50.          item " [ ] &Archive"
  51.          item " [ ] &Hidden"
  52.          item " [ ] &Read Only "
  53.          item " [ ] &System"
  54.        end) '' (upcase attr)  "AHRS"
  55.  
  56.     // ok/cancel buttons
  57.     button "O&k"     21  3 8
  58.     button "Cancel"  21  5 8
  59.  
  60.     // display dialog box
  61.     if (getdialog ref attr) == 'Ok' then
  62.       if? attr (locase attr) ' '
  63.     end
  64.   else
  65.     ask "Enter attributes [AHRS] for " + file '' (sub '─' '' attr)
  66.   end
  67. end
  68.  
  69. // called by fcommand for file manager
  70. function fattr2 (file attr)
  71.   if file [LAST_CHAR] == '\\' then
  72.     file [LAST_CHAR] = ''
  73.   end
  74.   if setfileattr file attr then
  75.     fupdate file
  76.   else
  77.     ferror "Change attributes"
  78.   end
  79. end
  80.  
  81. // fmgr change attributes command
  82. if wintype? "fmgr" then
  83.   if not fmark? then
  84.     file = fgetfile
  85.     if file [LAST_CHAR] == '\\' then
  86.       file [LAST_CHAR] = ''
  87.     end
  88.     attr = getfileinfo file 'a'
  89.   end
  90.   attr = askattr fname [1..13] attr
  91.   if attr then
  92.     fcommand "fattr2" (locase attr)
  93.   end
  94.  
  95. // edit windows
  96. elseif wintype? "edit" then
  97.   file = getbufname
  98.   attr = askattr (getname file) (getfileinfo file 'a')
  99.   if attr then
  100.     if not setfileattr file attr then
  101.       msgbox "Change attributes failed!"
  102.     end
  103.   end
  104.  
  105. else
  106.   msgbox "Edit Windows or File Manager Windows Only!"
  107. end
  108.